This post describes how to leverage Chef and Test Kitchen to create a pristine virtual machine from which to create an RPM package.
Background
I needed customized versions of the FcgiWrap and Postfix RPM packages and preferred to develop a method that would allow me to periodically update the packages as new versions of the upstream source were released. Vagrant is a great tool for managing virtual machines and I was originally going to use this to provision a new VM to build the packages. I developed Chef cookbooks to provision the VMs, and while developing integration tests for the provisioners, I realized that it was more effective to use Test Kitchen to build and test my VMs (which itself uses Vagrant).
Prerequisites
The following are required:
- Git (v2.2.1 used)
- Ruby (v2.1.5 used)
- Chef (v11.16.4 used)
- Test Kitchen (v1.2.1 used)
- Vagrant (v1.6.5 used)
- Virtual machine (Parallels 10.0.0 used, but VirtualBox works as well)
Example / FcgiWrap
Clone the repository and use kitchen
to converge the node:
|
|
You can now transfer the .rpm
file to the target machine(s) and install via rpm
or yum
.
Example / Postfix
Clone the repository and use kitchen
to converge the node:
|
|
You can now transfer the .rpm
file to the target machine(s) and install via rpm
or yum
.
Summary
Test Kitchen is not only effective at performing integration testing for a Chef cookbook, it is also useful to spin up a pristine virtual machine to perform tasks such as building an RPM package.
((( - )))
References
Cookbook Sources:
- 4-20ma / FcgiWrap RPM Cookbook – builds FcgiWrap RPM
- 4-20ma / Postfix RPM Cookbook – builds Postfix RPM
3rd party software used (alphabetical):